﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script src="../bootstrap/js/jquery.min.js"></script>
    <script src="../bootstrap/js/bootstrap.min.js"></script>
    <!--[if lt IE 9]>
        <script src="bootstrap/js/html5shiv.min.js"></script>
        <script src="bootstrap/js/respond.min.js"></script>
    <![endif]-->
    <script src="../config.js"></script>
    <script src="../bootstrap/js/Common.js"></script>
    <script src="../bootstrap/js/controls.js"></script>
    <script type="text/javascript">
        //var autoReset = '[{ "Text": "自动解除报警", "Value":true }, { "Text": "手动解除报警", "Value":false }]';
        //var trendLock = '[{ "Text": "启用趋势锁定", "Value":true }, { "Text": "禁用趋势锁定", "Value":false}]';
        //var lockAlarm = '[{ "Text": "锁定报警信号", "Value":true }, { "Text": "解锁报警信号", "Value":false}]';
        $(function() {
            var formOption = {
                items: [
                    {
                        name: "triggerRuleId",
                        title: "编号",
                        field: "triggerRuleId",
                        type: "text",
                        readonly: GetUrlParam("mode") != "1"
                    }, {
                        name: "name",
                        title: "名称",
                        field: "name",
                        type: "text"
                    }, {
                        name: "autoReset",
                        title: "启用报警自动解除",
                        field: "autoReset",
                        //source: autoReset,
                        type: "checkbox"
                    }, {
                        name: "trendLock",
                        title: "启用趋势锁定",
                        field: "trendLock",
                        //source: trendLock,
                        type: "checkbox"
                    }, {
                        name: "lockAlarm",
                        title: "启用报警信号锁定",
                        field: "lockAlarm",
                       // source: lockAlarm,
                        type: "checkbox"
                    }
                ]
            };
            $(".form-horizontal").form(formOption).load(host_name + "rule/single?id=" + GetUrlParam("identity"),
                function () {
                    if (GetUrlParam("mode") == "1") {
                        document.getElementById("identity").addEventListener("keyup",
                            function () {
                                this.value = this.value.replace(/[^\w\-]/g, '');
                            }
                        );
                    }
                });
        });
        function Save() {
            var action = GetUrlParam("mode") == "1" ? "add" : "update";
            $(".form-horizontal")[0][2].value = $(".form-horizontal")[0][2].checked;
            $(".form-horizontal")[0][3].value = $(".form-horizontal")[0][3].checked;
            $(".form-horizontal")[0][4].value = $(".form-horizontal")[0][4].checked;
            return $(".form-horizontal").form().save(host_name + "rule/" + action);
        }
    </script>
</head>
<body>
    <div class="container">
        <form class="form-horizontal"></form>
    </div>
</body>
</html>